import { _decorator, Component, Label, Node, Prefab, resources ,instantiate, Vec3} from 'cc';
const { ccclass, property } = _decorator;
import WebSocketManager from '../Framework/Utils/ws/WebSocketManager';
import { EventMgr } from '../Framework/Managers/EventMgr';
import { WSCmd } from '../Framework/Utils/ws/wsCmd';
import { UIMgr } from '../Framework/Managers/UIMgr';
import { Globle } from '../Framework/Utils/Globle';
import { HttpUtil } from '../Framework/Managers/HttpUtil';

@ccclass('home')
export class home extends Component {
    @property(Label)
    public playerName:Label;
    currentPrefab:Prefab
    clickRoomBool:Boolean = true;
    protected onLoad(): void {
        WebSocketManager.instance.connect();
        EventMgr.Instance.AddEventListener("enterRoomNotify",this,this.enterRoom)
        EventMgr.Instance.AddEventListener("loginRes",this,this.loginRes);
        
    }
    
    start() {
    }
    update(deltaTime: number) {
        
    }

    loginRes(cmd,data){
        console.log("个人数据",data)
        Globle.loginData = data;
    }

    clickRoom(roomId){
        if(this.clickRoomBool){
            WebSocketManager.instance.enterRoom(roomId.currentTarget._siblingIndex);
            this.clickRoomBool = true;
            UIMgr.Instance.ClearAll();
            UIMgr.Instance.ShowUIView("GamePage");
        }
    }
    enterRoom(cmd,data){
        Globle.enterRoomData = data;
        console.log("enterRoom",Globle.enterRoomData)
    }
 
}


